Refactor tests of xc module#7475
Open
mohanchen wants to merge 4 commits into
Open
Conversation
added 2 commits
June 16, 2026 22:28
…ion parameters for nspin, domag, domag_z
This commit decouples XC_Functional and related libxc functions from the global PARAM object by adding explicit parameters: 1. Modified XC_Functional::v_xc() to accept nspin, domag, domag_z parameters instead of accessing PARAM 2. Modified XC_Functional::gradcorr() to accept nspin, domag, domag_z parameters 3. Modified XC_Functional::set_xc_type() to accept nspin parameter 4. Modified XC_Functional_Libxc::v_xc_libxc() to accept nspin, domag, domag_z parameters 5. Modified XC_Functional_Libxc::v_xc_meta() to accept nspin parameter Updated all call sites in: - source_estate/module_pot/pot_xc.cpp - source_estate/module_pot/pot_xc_fdm.cpp - source_pw/module_pwdft/forces_cc.cpp - source_pw/module_pwdft/stress_cc.cpp - source_hamilt/module_xc/xc_pot.cpp - source_hamilt/module_xc/libxc_pot.cpp - source_hamilt/module_xc/libxc_abacus.h Updated test files to remove PARAM dependencies: - test_xc3.cpp: Removed PARAM include and initialization - test_xc5.cpp: Removed PARAM include and initialization, updated v_xc, v_xc_meta calls - xctest.h: Removed PARAM include and initialization Default parameter values are provided for backward compatibility.
added 2 commits
June 17, 2026 09:04
…prove parameter passing Summary of changes: 1. Modified libxc_abacus.h: - Removed default value (=1) for nspin parameter in v_xc_libxc - Removed default value (=nullptr) for scaling_factor parameter in v_xc_libxc 2. Modified xc_functional.h: - Changed set_xc_type signature to only accept const std::string xc_func_in - Removed nspin and basis_type parameters from set_xc_type - Removed default parameters from v_xc and gradcorr 3. Modified xc_functional.cpp: - Updated set_xc_type implementation to match new signature - Removed meta-GGA nspin=4 check from set_xc_type (moved to gradcorr) - Removed hybrid functional LCAO check from set_xc_type (no longer needed) - Updated internal set_xc_type calls to use single parameter 4. Modified xc_grad.cpp: - Added meta-GGA nspin=4 check at the beginning of gradcorr function - This is the correct place for runtime validation since nspin is known here 5. Modified xc_pot.cpp: - Updated v_xc_libxc call to pass parameters correctly 6. Modified libxc_pot.cpp: - Updated v_xc_libxc implementation to match new signature 7. Modified stress_gga.cpp: - Changed direct 'true' argument to named variable 'is_stress' for gradcorr call - Improved code readability and maintainability 8. Updated all set_xc_type call sites (12 files): - test_xc.cpp, test_xc1.cpp, test_xc2.cpp, test_xc3.cpp, test_xc5.cpp - xc_functional.cpp, esolver_double_xc.cpp, esolver_ks_lcaopw.cpp - esolver_fp.cpp, Exx_LRI_interface.hpp, xc_kernel.cpp, exx_helper.cpp - All calls now pass only the xc_func_in parameter 9. Updated test_xc3.cpp and test_xc5.cpp: - Added named variables (nspin1, nspin2, nspin4, domag, domag_z, domag_true) - Removed direct numeric literals in function calls Rationale: - Separated functional setup (set_xc_type) from runtime configuration (nspin, basis_type) - Runtime validation checks moved to actual computation functions (gradcorr) - Parameter passing improved with meaningful variable names instead of magic numbers - Code readability and maintainability enhanced - Preparation for future improvements to XC functional interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.